package com.tdma.g12.provider;

import com.tdam.g12.soporte.Constantes;
import com.tdam.g12.soporte.Contacto;
import com.tdam.g12.soporte.Historial;

import com.tdma.g12.sql.ContactoSMSWebHelper;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;

public class HistorialProvider extends ContentProvider
{
	//Definicion del CONTENT_URI
	private static final String uri = "content://com.tdma.g12.historialprovider";
	public static final Uri CONTENT_URI = Uri.parse(uri);
		
	private ContactoSMSWebHelper _dataBaseHelper;
	
	Contacto contacto = null;
	
	public void setContacto (Contacto contacto)
	{
		this.contacto = contacto;
	}
	
	@Override
	public int delete(Uri uri, String selection, String[] idExternos)
	{
		// TODO Auto-generated method stub
		if (idExternos.length > 0)
		{
			_dataBaseHelper.DelHistorial(idExternos);
			return 1;	
		}
		return 0;
	}

	@Override
	public String getType(Uri uri)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Uri insert(Uri uri, ContentValues values)
	{
		// TODO Auto-generated method stub
		if (values.size() > 0)
		{
			_dataBaseHelper.AddItemHistorial( (Historial) values.get(Constantes.ITEM_HISTORIAL) );	
		}
		return null;
	}

	@Override
	public boolean onCreate()
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Cursor query(Uri uri, String[] projection, String selection,
			String[] idContacto, String sortOrder)
	{
		// TODO Auto-generated method stub
		return _dataBaseHelper.getHistorialContacto(idContacto);
	}

	@Override
	public int update(Uri uri, ContentValues values, String selection,
			String[] selectionArgs)
	{
		// TODO Auto-generated method stub
		return 0;
	}
	

}
